package com.pengtu.gsj.service.impl.jsbz;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.dao.jsbz.InfoManagementDao;
import com.pengtu.gsj.entity.app.Attachment;
import com.pengtu.gsj.entity.jsbz.InfoManagement;
import com.pengtu.gsj.service.jsbz.InfoManagementService;
import com.pengtu.gsj.service.system.SystemManageService;

@Transactional
@Service
public class InfoManagementServiceImpl implements InfoManagementService{
	
	@Autowired
	private InfoManagementDao infoManagementDao;
	
	@Autowired
	private SystemManageService systemManageService;
	
	//查询
	@Override
	public Page<InfoManagement> findInfoManagements(Page<InfoManagement> page,
			QueryFilter queryFilter) {
		return infoManagementDao.findPage(page, queryFilter);
	}
	
	//保存
	@Override
	public void saveInfoManagement(InfoManagement infoManagement){
		infoManagementDao.save(infoManagement);
	}
	//根据ID查询数据
	@Override
	public InfoManagement getInfoManagementById(String id){
		return infoManagementDao.get(id);
	}
	
	//删除
	public void  delateInfoManagement(InfoManagement infoManagement){
		if(infoManagement.getAttachments() != null){
			for(Attachment attachment : infoManagement.getAttachments()){
				systemManageService.deleteAttachment(attachment);
			}
		}
		infoManagementDao.delete(infoManagement);
	}
	
	//获取信息化管理系统的所有系统
	@Override
	public List<InfoManagement> getDigitalGroupBySystemName(QueryFilter queryFilter){
		return infoManagementDao.find(queryFilter);
	}
}
